<template>
  <el-card class="box-card">
    <div class="bar-chart" ref="redContainer"></div>
  </el-card>
</template>

<script>
import * as echarts from "echarts";
export default {
  name: "CardUser",
  components: {},
  data() {
    return {
      chart: null,
      option: {
        tooltip: {
          trigger: "axis",
          showContent: true,
        },

        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },

        xAxis: {
          type: "category",
          boundaryGap: true,
          data: [
            "20191001",
            "20191002",
            "20191003",
            "20191004",
            "20191005",
            "20191006",
            "20191007",
          ],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            name: "oppo",
            type: "line",
            data: [120, 132, 101, 134, 90, 230, 210],
          },
          {
            name: "vivo",
            type: "line",
            data: [220, 182, 191, 234, 290, 330, 310],
          },
          {
            name: "苹果",
            type: "line",
            data: [150, 232, 201, 154, 190, 330, 410],
          },
          {
            name: "小米",
            type: "line",
            data: [320, 332, 301, 334, 390, 330, 320],
          },
          {
            name: "三星",
            type: "line",
            data: [820, 932, 901, 934, 1290, 1330, 1320],
          },
          {
            name: "魅族",
            type: "line",
            data: [520, 1232, 1101, 434, 890, 2330, 1520],
          },
        ],
      },
    };
  },
  mounted() {
    console.log("this.$refs.redContainer", this.$refs.redContainer);
    this.chart = echarts.init(this.$refs.redContainer);
    this.chart.setOption(this.option);
  },
  // watch: {
  //   xData() {
  //     this.option.xAxis.data = this.xData;
  //     // 绘制 图表
  //     this.chart.setOption(this.option);
  //   },
  //   yData() {
  //     this.option.series[0].data = this.yData;
  //     // 绘制 图表
  //     this.chart.setOption(this.option);
  //   },
  // },
};
</script>

<style scoped lang="scss">
.bar-chart {
  // background-color: #ccc;s
  width: 530px;
  height: 280px;
}
:deep(.el-card__body) {
  padding: 0 20px 20px 20px;
}
</style>
